Ext.define('DragonApp.view.menu.MenuTreeController', {
    extend: 'Ext.app.ViewController',

    alias: 'controller.treemenu',

    treeNodeSelect: function(me, record, item, index, e, eOpts) {


        if (record.get('leaf')) {

            var mainPanel = Ext.ComponentQuery.query('mainpanel')[0];

            var newTab = mainPanel.items.findBy(
                function(tab) {
                    return tab.title === record.get('text');
                });

            if (!newTab) {

                var item_node = Ext.create('widget.' + record.get('classname'), {});

                newTab = mainPanel.add({
                    title: record.get('text'),
                    items: [item_node],
                    bodyPadding: 0,
                    closable: true,
                    closeAction: 'destroy'
                });
            }

            //焦点
            mainPanel.setActiveTab(newTab);
        }
    }
});